
var JQuery = jQuery.noConflict();
var bfSummarizers = new Array();
var bfDeactivateField = new Array();
var bfDeactivateSection = new Array();
			
function bfCheckMaxlength(id, maxlength, showMaxlength){
    if( JQuery("#ff_elem"+id).val().length > maxlength ){
        JQuery("#ff_elem"+id).val( JQuery("#ff_elem"+id).val().substring(0, maxlength) );
    }
    if(showMaxlength){
        JQuery("#bfMaxLengthCounter"+id).text( "(" + (maxlength - JQuery("#ff_elem"+id).val().length) + " chars left)" );
    }
}
function bfRegisterSummarize(id, connectWith, type, emptyMessage, hideIfEmpty){
    bfSummarizers.push( {
        id : id, 
        connectWith : connectWith, 
        type : type, 
        emptyMessage : emptyMessage, 
        hideIfEmpty : hideIfEmpty
    } );
}
function bfField(name){
    var value = "";
    switch(ff_getElementByName(name).type){
        case "radio":
            if(JQuery("[name="+ff_getElementByName(name).name+"]:checked").val() != "" && typeof JQuery("[name="+ff_getElementByName(name).name+"]:checked").val() != "undefined"){
                value = JQuery("[name="+ff_getElementByName(name).name+"]:checked").val();
                if(!isNaN(value)){
                    value = Number(value);
                }
            }
            break;
        case "checkbox":
        case "select-one":
        case "select-multiple":
            var nodeList = document["ff_form34"][""+ff_getElementByName(name).name+""];
            if(ff_getElementByName(name).type == "checkbox" && typeof nodeList.length == "undefined"){
                if(typeof JQuery("[name="+ff_getElementByName(name).name+"]:checked").val() != "undefined"){
                    value = JQuery("[name="+ff_getElementByName(name).name+"]:checked").val();
                    if(!isNaN(value)){
                        value = Number(value);
                    }
                }
            } else {
                var val = "";
                for(var j = 0; j < nodeList.length; j++){
                    if(nodeList[j].checked || nodeList[j].selected){
                        val += nodeList[j].value + ", ";
                    }
                }
                if(val != ""){
                    value = val.substr(0, val.length - 2);
                    if(!isNaN(value)){
                        value = Number(value);
                    }
                }
            }
            break;
        default:
            if(!isNaN(ff_getElementByName(name).value)){
                value = Number(ff_getElementByName(name).value);
            } else {
                value = ff_getElementByName(name).value;
            }
    }
    return value;
}
function populateSummarizers(){
    // cleaning first
    for(var i = 0; i < bfSummarizers.length; i++){
        JQuery("#"+bfSummarizers[i].id).parent().css("display", "");
        JQuery("#"+bfSummarizers[i].id).html("<span class=\"bfNotAvailable\">"+bfSummarizers[i].emptyMessage+"</span>");
    }
    for(var i = 0; i < bfSummarizers.length; i++){
        var summVal = "";
        switch(bfSummarizers[i].type){
            case "bfTextfield":
            case "bfTextarea":
            case "bfHidden":
            case "bfCalendar":
            case "bfFile":
                if(JQuery("[name=ff_nm_"+bfSummarizers[i].connectWith+"[]]").val() != ""){
                    JQuery("#"+bfSummarizers[i].id).text( JQuery("[name=ff_nm_"+bfSummarizers[i].connectWith+"[]]").val() ).html();
                    var breakableText = JQuery("#"+bfSummarizers[i].id).html().replace(/\r/g, "").replace(/\n/g, "<br/>");
								
                    if(breakableText != ""){
                        var calc = null;
                        eval( "calc = typeof bfFieldCalc"+bfSummarizers[i].id+" != \"undefined\" ? bfFieldCalc"+bfSummarizers[i].id+" : null" );
                        if(calc){
                            breakableText = calc(breakableText);
                        }
                    }
								
                    JQuery("#"+bfSummarizers[i].id).html(breakableText);
                    summVal = breakableText;
                }
                break;
            case "bfRadioGroup":
            case "bfCheckbox":
                if(JQuery("[name=ff_nm_"+bfSummarizers[i].connectWith+"[]]:checked").val() != "" && typeof JQuery("[name=ff_nm_"+bfSummarizers[i].connectWith+"[]]:checked").val() != "undefined"){
                    var theText = JQuery("[name=ff_nm_"+bfSummarizers[i].connectWith+"[]]:checked").val();
                    if(theText != ""){
                        var calc = null;
                        eval( "calc = typeof bfFieldCalc"+bfSummarizers[i].id+" != \"undefined\" ? bfFieldCalc"+bfSummarizers[i].id+" : null" );
                        if(calc){
                            theText = calc(theText);
                        }
                    }
                    JQuery("#"+bfSummarizers[i].id).text( theText );
                    summVal = theText;
                }
                break;
            case "bfCheckboxGroup":
            case "bfSelect":
                var val = "";
                var nodeList = document["ff_form34"]["ff_nm_"+bfSummarizers[i].connectWith+"[]"];
							
                for(var j = 0; j < nodeList.length; j++){
                    if(nodeList[j].checked || nodeList[j].selected){
                        val += nodeList[j].value + ", ";
                    }
                }
                if(val != ""){
                    var theText = val.substr(0, val.length - 2);
                    if(theText != ""){
                        var calc = null;
                        eval( "calc = typeof bfFieldCalc"+bfSummarizers[i].id+" != \"undefined\" ? bfFieldCalc"+bfSummarizers[i].id+" : null" );
                        if(calc){
                            theText = calc(theText);
                        }
                    }
                    JQuery("#"+bfSummarizers[i].id).text( theText );
                    summVal = theText;
                }
                break;
        }
					
        if( ( bfSummarizers[i].hideIfEmpty && summVal == "" ) || ( typeof bfDeactivateField != "undefined" && bfDeactivateField["ff_nm_"+bfSummarizers[i].connectWith+"[]"] ) ){
            JQuery("#"+bfSummarizers[i].id).parent().css("display", "none");
        }
    }
}
		
var bfUseErrorAlerts = false;

function bfShowErrors(error){
    JQuery(".bfErrorMessage").html("");
    JQuery(".bfErrorMessage").css("display","none");
    JQuery(".bfErrorMessage").fadeIn(1500);
    var allErrors = "";
    var errors = error.split("\n");
    for(var i = 0; i < errors.length; i++){
        allErrors += "<div class=\"bfError\">" + errors[i] + "</div>";
    }
    JQuery(".bfErrorMessage").html(allErrors);
    JQuery(".bfErrorMessage").css("display","");
}
function bfFade(){
    JQuery(".bfPageIntro").fadeIn(1000);
    var size = 0;
    JQuery(".bfFadingClass").each(function(i,val){
        var t = this;
        setTimeout(function(){
            JQuery(t).fadeIn(1000)
            }, (i*100));
        size = i;
    });
    setTimeout('JQuery(".bfSubmitButton").fadeIn(1000)', size * 100);
    setTimeout('JQuery(".bfPrevButton").fadeIn(1000)', size * 100);
    setTimeout('JQuery(".bfNextButton").fadeIn(1000)', size * 100);
    setTimeout('JQuery(".bfCancelButton").fadeIn(1000)', size * 100);
}
				
var bfElemWrapBg = "";
function bfSetElemWrapBg(){
    bfElemWrapBg = JQuery(".bfElemWrap").css("background-color");
}
function bfRollover() {
    JQuery(".ff_elem").focus(
        function(){
            var parent = JQuery(this).parent();
            if(parent && parent.attr("class").substr(0, 10) == "bfElemWrap"){
                parent.css("background-color","#ffc");
            } else {
                parent = JQuery(this).parent().parent();
                parent.css("background-color","#ffc");
            }
        }
        ).blur(
        function(){
            var parent = JQuery(this).parent();
            if(parent && parent.attr("class").substr(0, 10) == "bfElemWrap"){
                parent.css("background-color",bfElemWrapBg);
            } else {
                parent = JQuery(this).parent().parent();
                parent.css("background-color",bfElemWrapBg);
            }
        }
        );
}
function bfRollover2() {
    JQuery(".bfElemWrap").mouseover(
        function(){
            JQuery(this).css("background-color","#ffc");
        }
        );
    JQuery(".bfElemWrap").mouseout(
        function(){
            JQuery(this).css("background-color",bfElemWrapBg);
        }
        );
}
				
JQuery(document).ready(function() {
    if(typeof bfFade != "undefined")bfFade();
    if(typeof bfSetElemWrapBg != "undefined")bfSetElemWrapBg();
    if(typeof bfRollover != "undefined")bfRollover();
    if(typeof bfRollover2 != "undefined")bfRollover2();
    if(typeof bfRegisterToggleFields != "undefined")bfRegisterToggleFields();
    if(typeof bfDeactivateSectionFields != "undefined")bfDeactivateSectionFields();
    JQuery(".hasTip").css("color","inherit"); // fixing label text color issue
    JQuery(".bfTooltip").css("color","inherit"); // fixing label text color issue
});
		

function MM_preloadImages()
{ //v3.0
    var d = document;
    if (d.images)
    {
        if(!d.MM_p)
            d.MM_p = new Array();
        var i,j = d.MM_p.length,a = MM_preloadImages.arguments;
        for(i=0; i < a.length; ++i)
            if (a[i].indexOf("#") != 0)
            {
                d.MM_p[j] = new Image;
                d.MM_p[j++].src = a[i];
            }
    }
}
		
		
function MM_swapImgRestore()
{ //v3.0
    var i,x,a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; ++i)
        x.src = x.oSrc;
}
		
		
function MM_findObj(n, d)
{ //v4.01
    var p,i,x;
    if (!d)
    {
        d = document;
    }
    if ((p = n.indexOf("?")) > 0 && parent.frames.length)
    {
        d = parent.frames[n.substring(p+1)].document;
        n = n.substring(0,p);
    }
    if (!(x = d[n]) && d.all)
    {
        x = d.all[n];
    }
    for (i = 0; !x && i < d.forms.length; ++i)
    {
        x = d.forms[i][n];
    }
    for(i = 0; !x && d.layers && i < d.layers.length; ++i)
    {
        x = MM_findObj(n,d.layers[i].document);
    }
    if (!x && d.getElementById)
    {
        x = d.getElementById(n);
    }
    return(x);
}
		
		
function MM_swapImage()
{ //v3.0
    var i,j=0,x,a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for(i=0; i < (a.length-2); i += 3)
    {
        if ((x = MM_findObj(a[i])) != null)
        {
            document.MM_sr[j++] = x;
            if (!x.oSrc)
            {
                x.oSrc = x.src;
            }
            x.src = a[i+2];
        }
    }
}
   
       	
var YtSettings = {
    tplurl: '/templates/yoo_explorer', 
    color: 'sports'
};